Page({
  data: {
    camera: "front",
    imageSrc: "",
    videoSrc: "",
  },

  front: function () {
    console.log("font");
    this.setData({
      camera: "front",
    })
  },


  back: function () {
    console.log("back");
    this.setData({
      camera: "back",
    })
  },


  change: function () {
    if (this.data.camera = "front") {
      this.setData({
        camera: "back",
      })
    } else {
      this.setData({
        camera: "front",
      })
    }
  },

  takephoto: function () {
    let tkpt = wx.createCameraContext()
    tkpt.takePhoto({
      quality: "high",
      success: (e) => {
        this.setData({
          imageSrc: e.tempImagePath,
        })
      }
    })
  },



  start: function () {
    let that = this;
    let camera = wx.createCameraContext();
    camera.startRecord({
      success: (e) => {
        console.log("开始录像")
        that.setData({
        })
      },
    })
  },

  stop: function () {
    let that = this;
    let camera = wx.createCameraContext();
    camera.stopRecord({
      success: (e) => {
        console.log("结束录像")
        that.setData({
          videoSrc: e.tempVideoPath,
        })
      },
    })
  },
})